package com.scalar.forecast.projectSetup.actions;

import com.scalar.forecast.ForecastExtendedAction;
import com.scalar.forecast.commons.SessionKeys;
import com.scalar.forecast.projectSetup.actionCommands.ProjectSetupActionCommandFactory;
import com.scalar.forecast.actionCommands.ActionCommand;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;

/** Action Class for processing the requests came from Project Setup Search Screen
 *
 * Created by Veeru. 
 * Date: Feb 7, 2005
 * Time: 5:46:42 PM 
 */


public class ProjectSetupAction extends ForecastExtendedAction {



    public ActionForward executeRequest( ActionMapping mapping,
                                         ActionForm form,
                                         HttpServletRequest request,
                                         HttpServletResponse response ) throws Exception {

        ActionForward actionForward = mapping.findForward("projectSetup");
        String action    = request.getParameter("action");
        HashMap errors = new HashMap ();
        request.setAttribute( SessionKeys.ERROR_MESSAGES, errors );

        try {
            if ( action == null ) {
                action = ACTION_NEW;
            }
            ActionCommand actionCommand = ProjectSetupActionCommandFactory.getActionCommand( action );
            actionForward = actionCommand.execute( mapping, form, request, response );

        } catch( Exception e){
             errors.put("Error while processing the Project Setup Action", null);
        }
        return actionForward ;
    }
}
